<?php

namespace app\batch;

use think\Db;

use think\console\Command;
use think\console\Input;
use think\console\Output;
use app\models\{Goods, OrderGoods, Compent, SystemGoods, PlatClass,Banner,BussinessSq,PlatSons,Recpeople,IntergralGoods,IntergralOrdergoods};

class Replar extends Command
{
    protected $open = false;
    protected function configure()
    {
        $this->setName('Replar')->setDescription('图片链接转换');
    }

    protected function execute(Input $input, Output $output)
    {
        $this->doCron();
        die();
    }

    protected function doCron()
    {
        (new SystemGoods())->chunk(1000, function ($lists) {
            $url = "https://" . Env('app.api_url');
            // foreach ($lists as $list) {
            //     $list['images'] = json_decode($list['images'],true);
            //     $list['images'] = str_replace("https://mjqd.ktz6688.com",$url, $list['images']);
            //     $list['images'] = str_replace("https://ddapi.tcwang888.com",$url, $list['images']);
            //     $list['images'] = json_encode($list['images'],true);
            //     $res = (new SystemGoods())->where('id', $list['id'])->update(['images' => $list['images']]);
            //     if ($res) {
            //         echo '成功';
            //     }
            // }
        });
    }
}
